// 创建一个简单的事件总线
class MapEventBus {
    constructor() {
        this.events = {};
    }

    // 订阅事件
    on(eventName, callback) {
        if (!this.events[eventName]) {
            this.events[eventName] = [];
        }
        this.events[eventName].push(callback);
    }

    // 触发事件
    emit(eventName, ...data) {
        if (this.events[eventName]) {
            this.events[eventName].forEach(callback => callback(...data));
        }
    }

    // 取消订阅
    off(eventName, callback) {
        if (this.events[eventName]) {
            this.events[eventName] = this.events[eventName].filter(cb => cb !== callback);
        }
    }
}

// 导出单例
export const mapEventBus = new MapEventBus();